{% extends "element/saas/base_mini.html" %}
{% load future wenlincms_tags wlcore_tags report_tags %}
{% block meta_title %}我的关注{% endblock %}

{% block extra_css %}
    <link rel="stylesheet" href="{{ STATIC_URL }}{{ "element/report/css/report.css"|file_time_stamp }}">
    {{ block.super }}
{% endblock %}
{% block main %}
    <div class="admin-content" id="saas_guanzhu">
        <div class="searchbox">
            <h4 class="secondtitle">添加关注企业</h4>

            <form class="am-form-inline" role="form">
                <div class="am-form-group">
                    <input name="ENTNAME" class="mini-autocomplete" valueField="ENTNAME"
                           textField="ENTNAME" popupEmptyText="查无数据" loadingText="加载中..."
                           vtype="rangeLength:2,100" url="/entmohu/" emptyText="企业全称">
                </div>
                <span class="am-btn am-btn-secondary am-btn-sm" id="searchCom">搜索</span>
            </form>
        </div>
        <div class="caredcom">
            <h4 class="secondtitle">已关注企业</h4>

            <div class="nocom">您暂时没有关注企业</div>
            <table class="am-table am-table-radius am-table-striped">
                <thead>
                <tr>
                    <th width="150" style="padding-left: 15px;">时间</th>
                    <th width="150">企业名称</th>
                    <th width="150">历史消息个数</th>
                    <th width="100">操作</th>
                </tr>
                </thead>

                <tbody>
                <tr>
                    <td class="uctime">2016-12-12</td>
                    <td>{{ sitesettings.website_corp }}</td>
                    <td>55</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-12</td>
                    <td>{{ sitesettings.website_corp }}</td>
                    <td>55</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-12</td>
                    <td>{{ sitesettings.website_corp }}</td>
                    <td>55</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-12</td>
                    <td>{{ sitesettings.website_corp }}</td>
                    <td>55</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                <tr>
                    <td class="uctime">2016-12-10</td>
                    <td>小米科技有限责任公司</td>
                    <td>159</td>
                    <td>
                        <span onclick="cancleAttention(1)" class="canclebtn">
                            <i class="am-icon-close"></i> 取消关注</span>
                    </td>
                </tr>
                </tbody>
            </table>

            <ul data-am-widget="pagination" class="am-pagination am-pagination-default saas_pagination"
                id="re_paginationC">
                <li class="am-pagination-prev preBtn">
                    <a href="javascript:void(0)">上一页</a>
                </li>
                <li class="am-pagination-next nextBtn">
                    <a href="javascript:void(0)">下一页</a>
                </li>
                <li class="jumpPage">
                    <div class="inBox">
                        跳转 <input class="mini-textbox" vtype="int" name="numinput2"
                                  width="60" height="30"/>&nbsp;&nbsp;/<em class="numBox">-</em>页
                    </div>
                    <em class="jumpbtn">确定</em>
                </li>
            </ul>
        </div>
        <div class="mesmethod">
            <h4 class="secondtitle">消息推送方式</h4>

            <div class="am-form-group">
                <label class="am-radio-inline" id="mesEmailBtn">
                    <input type="radio" value="" name="mesmethod"> 邮件
                </label>

                <div id="emailText">
                    <span class="emailbox"></span>
                    <span class="am-btn am-btn-default am-btn-sm changeemail">修改</span>
                </div>
                <div id="changeEmail">
                    <input class="mini-textbox" vtype="email;rangeLength:5,20;" id="mesEmail" name="mesEmail"
                           emptyText="输入电子邮件" required>
                    <span class="am-btn am-btn-default am-btn-xs cancleChange">取消</span>
                    <span class="am-btn am-btn-default am-btn-xs sureChange">确定</span>
                </div>
            </div>
        </div>
        {% include "element/saas/risk/company_basic.html" %}
        <div class="am-modal am-modal-alert" tabindex="-1" id="comSuccess">
            <div class="am-modal-dialog">
                <div class="am-modal-hd"></div>
                <div class="am-modal-bd" id="modalMSG">
                    关注成功！跳转中……
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block footer_js %}
    {{ block.super }}
    <script>
        mini.parse();
        var $modal = $('#attentionCom');
        var $comSuccess = $('#comSuccess');
        $("#searchCom").click(function () {
            $modal.modal('open');
        });
        $("#attentionCom .comCancel").click(function () {
            $modal.modal('close');
        });
        $("#attentionCom .comSure").click(function () {
            $modal.hide();
            $("#modalMSG").html("关注成功！跳转中……");
            $comSuccess.modal('open');
            setTimeout(function () {
                location.href = "/saas/guanzhu/";
            }, 1000);
        });
        function cancleAttention() {
            $("#modalMSG").html("取消成功！跳转中……");
            $comSuccess.modal('open');
            setTimeout(function () {
                location.href = "/saas/guanzhu/";
            }, 1000);
        }
        {#        移除添加click#}
        function clearcli() {
            $(".pageli").attr("onclick", "selectpage(this)");
            $(".preBtn").removeAttr("onclick");
            $(".nextBtn").removeAttr("onclick");
        }
        {#        消息推送方式#}
        var txt = $("#emailText .emailbox").text();
        function emailText() {
            if (txt) {
                $("#emailText").css("display", "inline-block");
                $("#changeEmail").hide();
            } else {
                $("#emailText").hide();
                $("#changeEmail").css("display", "inline-block");
            }
        }
        $("#changeEmail .cancleChange").click(function () {
            emailText();
        });
        $("#changeEmail .sureChange").click(function () {
            txt = mini.getbyName("mesEmail").getValue();
            var errorlen = $("#changeEmail .mini-error").length;
            if (errorlen < 1) {
                $("#emailText .emailbox").text(txt);
                emailText();
            }
        });
        $("#emailText .changeemail").click(function () {
            $("#emailText").hide();
            mini.getbyName("mesEmail").setValue(txt);
            $("#changeEmail").css("display", "inline-block");
        });
        $("#mesEmailBtn").click(function () {
            emailText();
        });
        {# 分页 #}
        var CNum = 1,
                cpage_total = 100;
        var getListC = function (num) {
            var pageallNum = Math.ceil(cpage_total / 20);
            $("#re_paginationC .numBox").text(cpage_total);
            pageTool(pageallNum, num, "re_paginationC");
            clearcli();
        };
        getListC(CNum - 1);
        var plists = $("#re_paginationC .pageli");
        addPageAc(CNum);
        $("#re_paginationC .jumpbtn").click(function () {
            var n = jumpage(CNum, getListC, "numinput2");
            if (n >= 0) {
                CNum = parseFloat(n) + 1;
                location.href = "/saas/account_main/?cpage=" + CNum
            }
        });
        {#        翻页#}
        $("#re_paginationC .nextBtn").click(function () {
            CNum++;
            jumpurl(CNum);
        });
        $("#re_paginationC .preBtn").click(function () {
            CNum--;
            jumpurl(CNum);
        });
        {#        active#}
        function addPageAc(num) {
            plists.each(function () {
                var _this = $(this);
                _this.removeClass("am-active");
                var _thisname = _this.attr("name");
                if (_thisname == num) {
                    _this.addClass("am-active");
                }
            })
        }
        function selectpage(_this) {
            var $this = $(_this);
            var _thisname = $this.attr("name");
            jumpurl(_thisname);
        }
        {#        跳转url#}
        function jumpurl(page) {
            if (!page) {
                page = 1;
            }
            {#                location.href = "/?cpage=" + page;#}
        }
    </script>
{% endblock %}
